<template>
  <!--登录条-->
  <div class="vLogobgDiv">
    <div class="vLogoContainer">
      <div class="vTitleDiv">
        <div class="fl">
          <img :src="logoImg" class="vImg"/>
          <span class="vName">{{title}}</span>
        </div>
        <div class="fr">
          <ul class="frList">
            <li class="vLip">
              {{userName}}（管理员），{{timeStr}}
            </li>
            <li>
              <a href="javascript:void(0)" @click="loginOut">
                <i class="iconfont icon-guanbi icon16 loginOutIcon"></i>
              </a>
            </li>
          </ul>
        </div>
      </div>
      <!-- <ul class="vMenuUl">
        <li v-for="menu in menuData">
          <router-link :to="{path:menu.path}" active-class="actived"><span>{{menu.name}}</span></router-link>
        </li>
      </ul> -->
    </div>
  </div>
</template>

<script>
  export default{
    data(){
      return{
        userName : sessionStorage.getItem('user'),
        logoImg: require('../../../static/theme/common/img/logo.png'),
        timeStr: "2019年1月01日 12:00:00",
        inter: null,
        title:''
      }
    },
    computed:{
      systemName(){
        return this.$store.getters.getSystemName;
      }
    },
    watch: {
      systemName(val) {
        this.title = val;
      }
    },
    created() {
      this.inter = setInterval(() => {
        let time = new Date();
        let m = time.getMonth() + 1;
        let t = time.getFullYear() + "年" + m + "月"
          + time.getDate() + "日 " + time.getHours() + ":"
          + (time.getMinutes() < 10 ? "0" + time.getMinutes() : time.getMinutes()) + ":" + (time.getSeconds() < 10 ? "0" + time.getSeconds() : time.getSeconds());
        this.timeStr = t;
      }, 1000);
      this.getconfig();
    },
    beforeDestroy() {
      clearInterval(this.inter);
    },
    methods:{
      getconfig(){
        this.axios.get("/api/config").then(res=>{
          this.systemName = res.data.systemName;
          this.$store.commit("setSystemName", res.data.systemName)
        })
      },
      //退出
      loginOut(){
        //返回到登录页面则清空sessionStorge值，让它重新存储
        sessionStorage.clear();
        localStorage.clear();
        this.$router.push('/login');
      }
    }
  }
</script>

<style>

</style>
